package com.yuke.cloud.service.smc.service.impl;

import com.yuke.cloud.common.core.support.BaseService;
import com.yuke.cloud.service.smc.dao.DmsSendMapper;
import com.yuke.cloud.service.smc.dto.DmsSendDto;
import com.yuke.cloud.service.smc.entity.DmsSend;
import com.yuke.cloud.service.smc.service.DmsSendService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.Map;


/**
 * Created by zn on 2020/07/16.
 */
@Service
@Transactional
public class DmsSendServiceImpl extends BaseService<DmsSend> implements DmsSendService {
    @Resource
    private DmsSendMapper dmsSendMapper;


//    @Resource
//    public List<DmsSendDto> findList(DmsSendDto dmsSendDto){
//        return dmsSendMapper.findList(dmsSendDto);
//    }

    @Override
    public List<DmsSend> selectSendByScope(DmsSend dmsSend){
        return dmsSendMapper.selectSendByScope(dmsSend);
    }

    @Override
    public List<DmsSendDto> selectSendByCondition(DmsSendDto dmsSendDto) {
        return dmsSendMapper.selectSendByCondition(dmsSendDto);
    }

    @Override
    public List<DmsSendDto> selectOtherList(DmsSendDto dmsSendDto) {
         return dmsSendMapper.selectOtherList(dmsSendDto);
    }

    @Override
    public List<DmsSendDto> selectSendOrderList(DmsSendDto dmsSendDto) {
        return dmsSendMapper.selectSendOrderList(dmsSendDto);
    }


    @Override
    public Map selectCountByCondition(DmsSendDto dmsSendDto) {
        return dmsSendMapper.getCountByCondition(dmsSendDto);
    }

    @Override
    public List<Map> sendOrderCountByGroup(DmsSendDto dmsSendDto) {
        return dmsSendMapper.sendOrderCountByGroup(dmsSendDto);
    }

    @Override
    public  Integer updateSendDeleteTag(Long orderId){
        DmsSend dmsSend = new DmsSend();
        dmsSend.setOrderId(orderId);
        List<DmsSend> dmsSendList = this.select(dmsSend);

        if (dmsSendList != null && dmsSendList.size() > 0){
            for (DmsSend send : dmsSendList){
                send.setDeleteTag((byte)1);
                send.setUpdateTime(new Date());
                this.update(send);

            }
            return 1;
        }
        return 0;
    }

}
